' This program exported from BASIC Anywhere Machine (Version [5.2.3].[2023.08.29.03.37]) on 2023.08.29 at 16:47 (Coordinated Universal Time)
' This program exported from BASIC Anywhere Machine (Version [5.2.3].[2023.08.29.03.37]) on 2023.08.29 at 16:47 (Coordinated Universal Time)
' Port to BASIC Anywhere Machine by Charlie Veniot
' of the "stars.bas" QBasic program found at https://www.bamsoftware.com/hacks/qbasic/index.html
' 🟠 BAM's PSET wraps around the screen when coordinates are outside of the screen size.  Compare marked lines below with original code

SCREEN 13

CONST NUM = 50
CONST INC = 40
CONST ICANSEE = 50

DIM as double x(1 TO NUM), y(1 TO NUM), z(1 TO NUM)

FOR i = 1 TO NUM
x(i) = RND * 320 - 160
y(i) = RND * 200 - 100
z(i) = RND * ICANSEE
NEXT

DO
FOR i = 1 TO NUM
this_x =  (INC * (x(i) / z(i)) + 160) : this_y = (INC * (y(i) / z(i)) + 100) ' 🟠
IF between(this_x,0,319) and between(this_y,0,199) THEN PSET (this_x, this_y), 0 ' 🟠
IF z(i) <= 1 THEN
z(i) = ICANSEE
x(i) = RND * 320 - 160
y(i) = RND * 200 - 100
ELSE
z(i) = z(i) - 1
END IF
this_x = INC * (x(i) / z(i)) + 160 : this_y = INC * (y(i) / z(i)) + 100 ' 🟠
IF between(this_x,0,319) and between(this_y,0,199) THEN PSET (this_x, this_y), z(i) MOD 17 + 15 ' 🟠
NEXT
_delay 0.04
LOOP